All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class quicktime.app.actions.PeriodicAction

java.lang.Object
   |
   +----quicktime.app.actions.PeriodicAction

public abstract class PeriodicAction
extends Object
implements Ticklish
This class is the base class for all periodically recurring time based actions. The Actionable object (if defined) will be an object that has its trigger method called when the PeriodicAction sub-class action is executed or when a constraining condition of the action is reached. The action is tickled periodically and whether it will do its action is dependant upon the time interval as specified by the scale and period and the time and effective rate of the tickle call. Every time the action is executed the time is kept and consequent calls to tickle result in a comparison between the new time, the rate and the last time the action was executed. Whether the action is executed is calculated by:
if (currentTime <= period / scale * 1000 / effectiveRate + lastTime) at rate > 0.
The tickle method is not called with an effectiveRate of 0. Whether the doAction method is called can also be affected by a flag that controls whether an action is triggered depending on rate settings.


Variable Index

 o actor
The actionable actor object that can be invoked by an action if a constraining condition is reached
 o reschedule
If true then the tickle method returns true and the action is considered to be still active by its owner and will be invoked on consequent tickles.

Constructor Index

 o PeriodicAction(int, int)
Create a PeriodicAction.

Method Index

 o constraintReached()
If after the doAction method has exeucted this method returns true then if the Action has an Actionable object this actionable is triggered.
 o doAction(float, int)
This method is called by the tickle method when an action becomes active.
 o equals(Object)
Returns true if the objects are equal or false otherwise.
 o getActionable()
This method retreives the current actor that is attached to the action
 o getPeriod()
Returns the current period of the action
 o getScale()
Return the current scale of the action.
 o getTriggerCondition()
Returns the trigger condition of the action - an action can trigger either when rate is positive, rate is negative or either.
 o setActionable(Actionable)
This method sets the actionable object of the action.
 o setPeriod(int)
Sets the current period of the action - how many scale ticks will elapse before the action is executed.
 o setScale(int)
Sets the scale of the action - this is the resolution of a second at rate == 1, thus a scale of 10 is 100msecs at rate == 1, 50msecs at rate == 2 etc.
 o setTriggerCondition(int)
Sets the trigger condition of the action - an action can trigger either when rate is positive, rate is negative or either.
 o tickle(float, int)
This method can be called as often as you like, though effective rate cannot be zero.
 o timeChanged(int)
This method should be called by the actions owner whenver a time condition of the owner's time line has changed, as this can effect the trigger conditions of the action.
 o toString()
Return a String representation of this object.

Variables

 o actor
 protected Actionable actor
The actionable actor object that can be invoked by an action if a constraining condition is reached

 o reschedule
 protected boolean reschedule
If true then the tickle method returns true and the action is considered to be still active by its owner and will be invoked on consequent tickles.

Constructors

 o PeriodicAction
 protected PeriodicAction(int scale,
                          int period)
Create a PeriodicAction. Subclasses are responsible for defining the action that occurs whenever the action is invoked.

Parameters:
scale - the amount with which a second is divided into at a rate of one
period - the number of scale ticks that elapse between invocations of the action.

Methods

 o timeChanged
 public void timeChanged(int newTime) throws QTException
This method should be called by the actions owner whenver a time condition of the owner's time line has changed, as this can effect the trigger conditions of the action.

Parameters:
the - new time expressed in Ticklish.kScale ticks
See Also:
Ticklish
 o tickle
 public boolean tickle(float effectiveRate,
                       int currentTime) throws QTException
This method can be called as often as you like, though effective rate cannot be zero. The provided time and rate values are used to calculate whether an action should be executed. If an action should be executed this method calls the doAction method which should perform the action.

Parameters:
er - the actual rate at which the action has been triggered
t - the time in Ticklish.kScale that the action has been triggered
Returns:
true if the action is still interested in being tickled.
 o doAction
 protected abstract void doAction(float er,
                                  int t) throws QTException
This method is called by the tickle method when an action becomes active. Subclasses should do their desired actions when this method is called.

Parameters:
er - the actual rate at which the action has been triggered
t - the time in Ticklish.kScale that the action has been triggered
 o constraintReached
 protected abstract boolean constraintReached()
If after the doAction method has exeucted this method returns true then if the Action has an Actionable object this actionable is triggered. If constraintReached returns false no further action is taken.

Returns:
true if the actionable object (if set) should be triggered
 o setActionable
 public void setActionable(Actionable actor)
This method sets the actionable object of the action.

 o getActionable
 public Actionable getActionable()
This method retreives the current actor that is attached to the action

 o setPeriod
 public void setPeriod(int period)
Sets the current period of the action - how many scale ticks will elapse before the action is executed. If the period is zero the doAction method is called whenever the PeriodicAction is tickled.

Parameters:
period - the new period
 o getPeriod
 public int getPeriod()
Returns the current period of the action

Returns:
the period
 o setScale
 public void setScale(int s)
Sets the scale of the action - this is the resolution of a second at rate == 1, thus a scale of 10 is 100msecs at rate == 1, 50msecs at rate == 2 etc. This value must be greater than zero.

Parameters:
s - the new scale or resolution of the action
 o getScale
 public int getScale()
Return the current scale of the action.

Returns:
the current scale
 o getTriggerCondition
 public int getTriggerCondition()
Returns the trigger condition of the action - an action can trigger either when rate is positive, rate is negative or either.

Returns:
the current trigger condition
See Also:
triggerTimeFwd, triggerTimeBwd, triggerTimeEither
 o setTriggerCondition
 public void setTriggerCondition(int cond)
Sets the trigger condition of the action - an action can trigger either when rate is positive, rate is negative or either.

Parameters:
cond - the current trigger condition
See Also:
triggerTimeFwd, triggerTimeBwd, triggerTimeEither
 o toString
 public String toString()
Return a String representation of this object.

Returns:
a String
Overrides:
toString in class Object
 o equals
 public boolean equals(Object obj)
Returns true if the objects are equal or false otherwise.

Parameters:
obj - the object to test
Returns:
a boolean
Overrides:
equals in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index